
#定义一个存放账号信息的列表变量

account=[
{'name':'zhangsan','balance':500},
{'name':'lisi','balance':1000},
{'name':'wangwu','balance':5000}]

#定义银行账户信息的输出函数

def showaccount(account):
	if len(account)==0:
		print("=======没有账户信息=======")
		return
	print("|{0:<5}| {1:10}| {2:8}|".format("sid","name","balance"))
	print("-"*40)
	for i in range(len(account)):
		print("|{0:<5}| {1:10}| {2:8}|".format(i+1,account[i]['name'],account[i]['balance']))


#输入初始界面
while True:
	print("="*12,"ATM存取款系统","="*13)
	print("{0:1} {1:13} {2:15}".format(" ","1.查询账户余额","2.取款"))
	print("{0:1} {1:17} {2:15}".format(" ","3.存款","4.退出"))
	print("="*40)

	key = input("请输入对应的选项数字: ")

	#通过if判断到对应的选项输出

	if key == "1":
		print("="*10,"账户当前余额为","="*10)
		showaccount(account)
		input("按回车键继续： ")
	elif key == "2":
		print("="*17,"取款","="*17)
		showaccount(account)
		sid1 = input("请输入您想操作的账户数字: ")
		debalance = input("请输入您想取出多少钱: ")
		account[int(sid1)-1]['balance'] =account[int(sid1)-1]['balance']-int(debalance)	
		print("="*7,"取完钱后账户信息为","="*7)
		showaccount(account)
		input("按回车键继续： ")
	elif key == "3":
		print("="*17,"存款","="*17)
		showaccount(account)
		sid2 = input("请输入您想操作的账户数字: ")
		addbalance = input("请输入您想存多少钱: ")
		account[int(sid2)-1]['balance'] =account[int(sid2)-1]['balance']+int(addbalance)	
		print("="*7,"存完钱后账户信息为","="*7)
		showaccount(account)
		input("按回车键继续： ")
	elif key == "4":
		print("="*10,"再见","="*10)
		break
	else:
		print("="*5,"您的输入有误，请重新输入","="*5)